package com.yc.demo.d0304;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "OnlinesServlet", value = "/Onlines.s")
public class OnlinesServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setContentType("text/html;charser=utf-8");
        //获取当前在线人数
        int size = OnlineListener.onlinedUser.size();
        PrintWriter out = response.getWriter();
        out.printf("<dl><dt>在线人数:%d",size);
        for (Object onlineUser : OnlineListener.onlinedUser) {
            out.printf("<dd>%s</dd>",onlineUser);
            
        }
        out.printf("</dt>");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
